var TEXT_MAX_SEARCH_TIME = 10000; //搜索控件时超时时间 http://doc.autoxjs.com/#/widgetsBasedAutomation?id=uiselectorfindonetimeout
var logUtils = require ('../log/logUtils');
module.exports = {
  logBounds (bounds) {
    var left = bounds.left;
    var right = bounds.right;
    var top = bounds.top;
    var bottom = bounds.bottom;
    logUtils.log (left, right, top, bottom);
  },
  inScreen (TextUI) {
    var bounds = TextUI.bounds ();
    var left = bounds.left;
    var right = bounds.right;
    var top = bounds.top;
    var bottom = bounds.bottom;
    return (
      left > 0 && right < device.width && top < device.height && bottom > 0
    );
  },
  existsText (text$) {
    if (text (text$).exists ()) {
      var TextUI = text (text$).findOne (TEXT_MAX_SEARCH_TIME);
      return TextUI ? TextUI : false;
    } else {
      return false;
    }
  },
  existsTextInSceen (text$) {
    var TextUI = this.existsText (text$);
    return TextUI ? this.inScreen (TextUI) : false;
  },
};
